//
//  UIViewController_iPhone.m
//  Pepperdine
//
//  Created by Michael Coats on 1/15/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "UIViewController_iPhone.h"
#import "MapAppViewController_iPhone.h"

@implementation UIViewController_iPhone

//@synthesize buttonMap, labelMap, button01, label01, button02, label02, button03, label03, button04, label04, button05, label05,
//button06, label06, button07, label07, button08, label08, button09, label09
@synthesize pageControl, bottomToolbar, barItemHome, scrollView;

-(IBAction)runMap:(id)sender {
//	MapAppViewController_iPhone *mapApp = [[MapAppViewController_iPhone alloc] initWithNibName:@"MapAppViewController_iPhone" bundle:[NSBundle mainBundle]];
//	UIView *subView = [mapApp view];
//	[self addSubview:subView];
//    [self makeKeyAndVisible];
}

/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
	[super viewDidLoad];
	[self.view setBackgroundColor:
     [UIColor colorWithPatternImage:
      [UIImage imageWithContentsOfFile:
       [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:
        @"background.png"]]]];
	scrollView.pagingEnabled = YES;
	[scrollView setContentSize:CGSizeMake(960.0f, 1.0f)];
	scrollView.showsHorizontalScrollIndicator = NO;
    scrollView.showsVerticalScrollIndicator = NO;
	scrollView.delegate = self;
	
	pageControl.numberOfPages = 3;
	pageControl.currentPage = 0;
	[pageControl addTarget:self action:@selector(pageTurn:) forControlEvents:UIControlEventValueChanged];
	
	
	UIButton *button01 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	button01.frame = CGRectMake(20, 20, 80, 80);
	[scrollView addSubview:button01];
	
	UIButton *button02 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	button02.frame = CGRectMake(120, 20, 80, 80);
	[scrollView addSubview:button02];
	
	UIButton *button03 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	button03.frame = CGRectMake(220, 20, 80, 80);
	[scrollView addSubview:button03];
	
	UIButton *button04 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	button04.frame = CGRectMake(20, 130, 80, 80);
	[scrollView addSubview:button04];
	
	UIButton *button05 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	button05.frame = CGRectMake(120, 130, 80, 80);
	[scrollView addSubview:button05];
	
	UIButton *button06 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	button06.frame = CGRectMake(220, 130, 80, 80);
	[scrollView addSubview:button06];
	
	UIButton *button07 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	button07.frame = CGRectMake(20, 240, 80, 80);
	[scrollView addSubview:button07];
	
	UIButton *button08 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	button08.frame = CGRectMake(120, 240, 80, 80);
	[scrollView addSubview:button08];
	
	UIButton *button09 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	button09.frame = CGRectMake(220, 240, 80, 80);
	[scrollView addSubview:button09];
	
	UIButton *button10 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	button10.frame = CGRectMake(340, 20, 80, 80);
	[scrollView addSubview:button10];
	
	UIButton *button11 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	button11.frame = CGRectMake(660, 50, 80, 80);
	[scrollView addSubview:button11];
	
	UILabel *label01 = UILabel.new;
	label01.frame = CGRectMake(20, 105, 80, 20);
	[scrollView addSubview:label01];
	label01.text = @"Label 01";
	label01.textAlignment = UITextAlignmentCenter;
	label01.backgroundColor = [UIColor clearColor];
	
	UILabel *label07 = UILabel.new;
	label07.frame = CGRectMake(20, 325, 80, 20);
	[scrollView addSubview:label07];
	label07.text = @"Label 07";
	label07.textAlignment = UITextAlignmentCenter;
	label07.backgroundColor = [UIColor clearColor];
}

- (void) pageTurn: (UIPageControl *) aPageControl
{
	int whichPage = aPageControl.currentPage;
	[UIView beginAnimations:nil context:NULL];
	[UIView setAnimationDuration:0.3f];
	[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
	scrollView.contentOffset = CGPointMake(320.0f * whichPage, 0.0f);
	[UIView commitAnimations];
}

- (void) scrollViewDidScroll: (UIScrollView *) aScrollView
{
	CGPoint offset = aScrollView.contentOffset;
	pageControl.currentPage = (offset.x + 160) / 320.0f;
}

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}

@end
